using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class KeyboardUIItem : MonoBehaviour
{
    void Start()
    {

    }

    // Update is called once per frame
    //void Update()
    //{

    //}

    public string character;//A B C
    public Text text;
    public Toggle toggle;
    public Image bg;
    private void OnValidate()
    {
        text.text = character;
    }

    public void SetSelect()
    {
        toggle.isOn = true;
    }

    public void SetRed()
    {
        bg.color = Color.red;
        if(_coroutine != null)
        {
            StopCoroutine(_coroutine);
        }
        _coroutine = StartCoroutine(CoResetColor());
    }

    private Coroutine _coroutine;
    private IEnumerator CoResetColor()
    {
        float time = 6f;
        for (float i = 0; i < time; i += Time.deltaTime)
        {
            bg.color = Color.Lerp(bg.color, Color.black, i/time);
            yield return null;
        }
    }
}
